package com.example.boot.rtorder.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.example.boot.rtorder.service.RtOrderService;
import com.example.boot.util.ResultData;
import com.example.boot.util.ResultUtil;

@RestController
public class RtOrderController {
	@Autowired
	private RtOrderService rtOrderService;

	@RequestMapping(value = "/add/order", method = RequestMethod.GET)
	public ResultData<Object> addOrder(@RequestParam(name = "orderStr", required = true) String orderStr,
			@RequestParam(name = "detailList", required = true) String detailList) throws Exception {
		return ResultUtil.success(rtOrderService.addOrder(orderStr, detailList));
	}

	@RequestMapping(value = "/user/order", method = RequestMethod.GET)
	public ResultData<Object> userOrder(@RequestParam(name = "openId", required = true) String openId)
			throws Exception {
		return ResultUtil.success(rtOrderService.userOrder(openId));
	}

}
